#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
int isprime(int n)
{
    int flag4 = 1;
    for (int k = 2; k <= sqrt(n); k++)
    {
        if (n % k == 0)
        {
            flag4 = 0;
        }
    }
    return flag4;
}
int main()
{
    int t = 0, d = 0;
    scanf("%d", &t);
    while (scanf("%d", &d) != EOF)
    {
        int count = 0;
        int arr[3] = { 0 };
        if (d < 9)
            printf("0");
        else
        {
            for (int a = 2; a <= d-1; a++)
            {
                int flag1 = 1;
                flag1 = isprime(a);
                if (flag1 == 1)
                    arr[0] = a;
                for (int b = 2; b <= d; b++)
                {
                    int flag2 = 1;
                    flag2 = isprime(b);
                    if (flag2 == 1)
                        arr[1] = b;
                    for (int c = 2; c <= d; c++)
                    {
                        int flag3 = 1;
                        flag3 = isprime(c);
                        if (flag3 == 1)
                        {
                            arr[2] = c;
                            if ((arr[0] + arr[1] + arr[2]) == d)
                                count++;
                        }
                    }
                }
            }
        }
        printf("%d\n", count);
    }
    return 0;
}